//
//  JSMLeavingFooterCollectionViewController.m
//  TakeYouTourTogether
//
//  Created by dllo on 15/12/2.
//  Copyright © 2015年 king. All rights reserved.
//

#import "JSMLeavingFooterCollectionViewController.h"
#import "JSMLeavingMoreProvinceTableViewCell.h"
#import "JSMLeavingMoreModel.h"
#import "JSMFooterProvinceDetailsViewController.h" //省份详情
#import "Header.h"

@interface JSMLeavingFooterCollectionViewController ()<UITableViewDataSource, UITableViewDelegate, JSMLeavingMoreProvinceTableViewCellDelegate>
@property(nonatomic, strong)BaseTableView *leavingMoreProvinceTableView;
@end

@implementation JSMLeavingFooterCollectionViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self createMoreProvinceTableView];
    self.title = @"全部专题";
}
- (void)createMoreProvinceTableView {
    self.leavingMoreProvinceTableView = [[BaseTableView alloc] initWithFrame:CGRectMake(0, 0, SCREENWIDTH, SCREENHEIGHT) style:UITableViewStyleGrouped];
    [self.view addSubview:self.leavingMoreProvinceTableView];
    self.leavingMoreProvinceTableView.dataSource = self;
    self.leavingMoreProvinceTableView.delegate = self;
    self.leavingMoreProvinceTableView.rowHeight = 150;
    
}
// 分区头
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
    return [self.moreArr[section] regionStr];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *reuse = @"reuse";
    JSMLeavingMoreProvinceTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse];
    if (!cell) {
        cell = [[JSMLeavingMoreProvinceTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuse];
    }
    cell.provincemarr = [self.moreArr[indexPath.section] provinceMarr];
    cell.delegate = self;
    return cell;
    
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return self.moreArr.count;
}

- (void)pushToDetailsPage:(NSString *)province {
    JSMFooterProvinceDetailsViewController *provinceDetails = [[JSMFooterProvinceDetailsViewController alloc] init];
    provinceDetails.provinceName = province;
    provinceDetails.formView = FromViewLeavingMoreProvinceViewController;

    [self.navigationController pushViewController:provinceDetails animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
